package com.hqyj.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

@Component
public class EmailUtile {
    @Autowired
    JavaMailSender javaMailSender;
    /**
     * @param email   发送给。。
     * @param subject 主题
     * @param content 内容
     */
    public boolean seandMail(String email, String subject, String content) {
        SimpleMailMessage simpleMailMessage = new SimpleMailMessage();

        simpleMailMessage.setFrom("1458631982@qq.com");

        simpleMailMessage.setTo(email);//发送给谁

        simpleMailMessage.setSubject(subject);//设置邮件主题

        simpleMailMessage.setText(content);//邮件内容

        try {
            javaMailSender.send(simpleMailMessage);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
}
